#!/bin/bash

mkdir -p /home/data/mysql
mkdir -p /home/logs/mysql

wget http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.28-29.3/binary/linux/x86_64/Percona-Server-5.5.28-rel29.3-388.Linux.x86_64.tar.gz
tar zxvf Percona-Server-5.5.28-rel29.3-388.Linux.x86_64.tar.gz

mv Percona-Server-5.5.28-rel29.3-388.Linux.x86_64 /usr/local/
ln -s /usr/local/Percona-Server-5.5.28-rel29.3-388.Linux.x86_64 /usr/local/mysql
cd /usr/local/mysql/

groupadd mysql
useradd -r -g mysql mysql

chown -R mysql:mysql /home/data/mysql
chown -R mysql:mysql /home/logs/mysql

chown -R mysql .
chgrp -R mysql .
yum -y install libaio # 使用mysql_install_db时的依赖库 
scripts/mysql_install_db --user=mysql --datadir=/home/data/mysql

cp /usr/local/mysql/bin/mysql  /usr/sbin/
cp support-files/my-medium.cnf /etc/my.cnf

#bin/mysqld_safe --user=mysql &

#cp support-files/mysql.server /etc/init.d/mysql